﻿<%@ Page Title="" Language="C#" MasterPageFile="~/AgentSite.Master" AutoEventWireup="true" CodeBehind="ChooseCustomer.aspx.cs" Inherits="Agents.Agent.ChooseCustomer" %>
<%@ Import Namespace="Agents.Data" %>
<asp:Content ID="Header" ContentPlaceHolderID="Header" runat="server">
</asp:Content>
<asp:Content ID="MainContent" ContentPlaceHolderID="MainContent" runat="server">
    <h1>
        בחירת הלקוח הבא
    </h1>            
    <hr />       

     סינון לפי שם: <asp:TextBox ID="txtCustomerName" runat="server" />
    <asp:Button ID="btnFilter" runat="server" UseSubmitBehavior="true" Text="סנן"
        OnClick="btnFilter_Click" CssClass="button"/>
    <asp:DataGrid runat="server" ID="DataGridProjects" AutoGenerateColumns="False"
        AllowPaging="True" PageSize="12" PagerStyle-Mode="NumericPages" 
        DataSourceID="SqlDataSource1" BackColor="White" BorderStyle="None" 
        CellPadding="3" GridLines="Both" Font-Size="Small"
        onpageindexchanged="DataGridProjects_PageIndexChanged" 
        oneditcommand="DataGridProjects_EditCommand1" 
        CssClass="dataGrid" Font-Names="Verdana" BorderColor="#999999" BorderWidth="1px">
        <AlternatingItemStyle BackColor="#DCDCDC" />
        <Columns>
            <asp:BoundColumn DataField="Id" Visible="false" />
            <asp:BoundColumn DataField="Name" HeaderText="שם לקוח" HeaderStyle-Width="20%" 
                                ItemStyle-Width="20%" FooterStyle-Width="20%"/>
            <asp:BoundColumn DataField="LastOrder" HeaderText="הזמנה אחרונה" HeaderStyle-Width="30%" 
                                ItemStyle-Width="30%" FooterStyle-Width="30%" />
            <asp:BoundColumn DataField="RegionName" HeaderText="אזור" HeaderStyle-Width="5%" 
                                ItemStyle-Width="5%" FooterStyle-Width="5%" />
            <asp:TemplateColumn HeaderText="כתובת" HeaderStyle-Width="30%" 
                                ItemStyle-Width="30%" FooterStyle-Width="30%">

                <ItemTemplate>
                    <asp:Label ID="lblAddress" runat="server" 
                        Text='<%# (new Agents.Queries()).
                        GetClient(Int32.Parse(Eval("Id").ToString())).GetAddress() %>' />
                </ItemTemplate>
            </asp:TemplateColumn>
            <asp:BoundColumn DataField="Phone" HeaderText="טלפון" HeaderStyle-Width="5%" 
                                ItemStyle-Width="5%" FooterStyle-Width="5%"/>
            <asp:BoundColumn DataField="ContactPerson" HeaderText="איש קשר" HeaderStyle-Width="5%" 
                                ItemStyle-Width="5%" FooterStyle-Width="5%"/>
            <asp:ButtonColumn CommandName="Edit" HeaderText="בחירה" Text="בחר" HeaderStyle-Width="5%" 
                                ItemStyle-Width="5%" FooterStyle-Width="5%"/>
        </Columns>
        <FooterStyle BackColor="#CCCCCC" ForeColor="Black" />
        <HeaderStyle BackColor="#000084" Font-Bold="True" ForeColor="White" />
        <ItemStyle BackColor="White" ForeColor="Black" />
        <PagerStyle Mode="NumericPages" BackColor="#999999" ForeColor="Black" 
        HorizontalAlign="Center"></PagerStyle>
        <SelectedItemStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" />
    </asp:DataGrid>

    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:AgentConnectionString %>" 
        SelectCommand="SELECT Clients.[Id], [City], [Street], [StreetNum], [Phone], 
                              [LastOrder], Clients.[Name], 
                              Regions.Name as RegionName, [ContactPerson] 
                        FROM [Clients] JOIN [Regions]
                        ON (Clients.Region = Regions.Id)
                        WHERE ([Status] = @Status) 
                        ORDER BY Name ASC">
        <SelectParameters>
            <asp:Parameter DefaultValue="פעיל" Name="Status" Type="String" />
        </SelectParameters>
    </asp:SqlDataSource>

    <br />           
    <hr />
    <div class="alignCenter">               
        <asp:Button ID="backBtn" Text="חזור" runat="server" onclick="backBtn_Click"  CssClass="button" />
    </div>
</asp:Content>
